import serializer as serializer
from django_redis import get_redis_connection
from rest_framework import serializers

from apps.tsukkomi.models import Spit
"""
[{"id":"5f315b50f852f3d0909d0072",
"content":"<p>啊额啊</p>",
"publishtime":"2020-08-10T14:36:00.134000+08:00",
"userid":null,
"nickname":null,
"visits":0,
"thumbup":0,
"comment":0,
"avatar":null,
"collected":false,
"hasthumbup":false,
"parent":null},
"""
# 查询吐槽
class GetlistSerializer(serializers.ModelSerializer):
    class Meta:
        model = Spit
        fields =['content','publishtime','userid','nickname','visits','thumbup',
                 'comment','avatar','collected','hasthumbup','parent']

"""
[{"id":"5f3206c98ac254f5749d0001",
"content":"哈哈哈",
"publishtime":"2020-08-11T02:47:37.147000+08:00",
"userid":"7",
"nickname":"admin",
"visits":0,
"thumbup":0,
"comment":0,
"avatar":"http://52.83.143.113:8888/group1/M00/00/02/rBFwiV5jUe-Ac_tWAAArGM-bl4A8023992",
"collected":false,
"hasthumbup":false,
"parent":"5f315b50f852f3d0909d0072"}]
"""
# 评论
class PinglunSerializer(serializers.ModelSerializer):
    parent =serializers.StringRelatedField()
    class Meta:
        model = Spit
        fields = ['id', 'content', 'publishtime', 'userid', 'nickname', 'visits', 'thumbup',
                  'comment', 'avatar', 'collected', 'hasthumbup', 'parent']

# 收藏
class PutShouCangSerzer(serializers.ModelSerializer):
    class Meta:
        model = Spit
        fields = ['collected']
# 点赞
class PutDianZanSerializer(serializers.ModelSerializer):
    class Meta:
        model = Spit
        fields = ['hasthumbup']








